using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using WozLib.UI.Ink.SketchObjects;
using System.Windows.Media;
using WozLib.UI.Ink.Adorners;

namespace WozLib.UI.Ink
{
  public class SketchInkCanvas : InkCanvas
  {
    public SketchInkCanvas()
    {
      // we are mostly just a wrapper
    }

    public virtual void Overlay(Point Position, MouseButtonState LeftButton, MouseButtonState MiddleButton, MouseButtonState RightButton)
    {
      // nothing really to do here - we let our children figure out what they want to do
    }

    public SketchObjectRegistry SketchObjectRegistry
    {
      get { return _SketchObjectRegistry; }
      set { _SketchObjectRegistry = value; }
    } private SketchObjectRegistry _SketchObjectRegistry;

    public delegate void UserCurrentInkToolChangedHandler(SketchPad.InkTools newInkTool,
      SketchPad.InkTools previousInkTool);

    public event UserCurrentInkToolChangedHandler UserCurrentInkToolChanged;

    public SketchPad.InkTools UserCurrentInkTool
    {
      get { return _UserCurrentInkTool; }
      set
      {
        SketchPad.InkTools oldValue = _UserCurrentInkTool;

        _UserCurrentInkTool = value;

        if (UserCurrentInkToolChanged != null)
        {
          UserCurrentInkToolChanged(value, oldValue);
        }

        //    // if changed because of a dropdown box or something
        //    // package up a SketchCommand it can be undone/redone
        //    // committed/autocommitted like any other command
        //    // 
        //    // we'll have to do the same thing for toolbar enabled
        //    // and a toolsEnabledCollection

        //    // if we just received this as an update from the client
        //    // we don't really do anything (because the databound combobox
        //    // is going to update to show the client has changed state.
        //    // we'll be able to queue off of this state to show 
      }
    } private SketchPad.InkTools _UserCurrentInkTool = SketchPad.InkTools.Pencil;

    public delegate void UserToolsEnabledCollectionChangedHandler(List<SketchPad.InkTools> newInkToolCollection,
      List<SketchPad.InkTools> previousInkToolCollection);

    public event UserToolsEnabledCollectionChangedHandler UserToolsEnabledCollectionChanged;

    public List<SketchPad.InkTools> UserToolsEnabledCollection
    {
      get { return _UserToolsEnabledCollection; }
      set 
      {
        List<SketchPad.InkTools> oldCollection = new List<SketchPad.InkTools>(_UserToolsEnabledCollection);

        _UserToolsEnabledCollection = value;

        if (UserToolsEnabledCollectionChanged != null)
        {
          UserToolsEnabledCollectionChanged(value, oldCollection);
        }
      }
    }
    private List<SketchPad.InkTools> _UserToolsEnabledCollection =
    new List<SketchPad.InkTools>(new SketchPad.InkTools[] { SketchPad.InkTools.Pencil, SketchPad.InkTools.Eraser });

    public void UpdateUserCurrentInkTool()
    {
      if (UserCurrentInkToolChanged != null)
      {
        UserCurrentInkToolChanged(UserCurrentInkTool, UserCurrentInkTool);
      }
    }

    public UIElement UIElementToAdorn
    {
      get { return _UIElementToAdorn; }
      set { _UIElementToAdorn = value; }
    } private UIElement _UIElementToAdorn = null;

    public HourglassAdorner HourglassAdorner
    {
      get { return _HourglassAdorner; }
      set { _HourglassAdorner = value; }
    } private HourglassAdorner _HourglassAdorner = null;


  }
}
